#include "Pacman.h"
//#include "ConsoleDemo.h"
#include <time.h>
//#ifdef PSX_PLATFORM_WINDOWS_CONSOLE
#include<string>
#include<string.h>
#include <iostream>
using namespace std;
//int x =2;
int score = 0;
int lives = 3;
int level = 1;



namespace Pulse
{
	PSX_REGISTER_APPLICATION_CREATE( Pacman )
		PSX_REGISTER_APPLICATION_RELEASE( )
		Enemy::Enemy( void )
		: x( 0 ), y( 0 ), xDir( -1 ), yDir( -1 ),Type("DEFAULT"),startPoint(0),Speed(10)
	{

	}

	void Pacman::ResetBulletPos(void) //This is used to reset BUllets after HIt 
	{
		Straight.y = m_player.y; //Added 7 coz M_player.y points to the tail of the ship image
		Straight.x = m_player.x;

	}



	void Enemy::Update( )//
	{
		Sleep(25);

		if ( x == startPoint+1 ) //this happens when enemy is hit
		{
			srand ( time(NULL) );
			y= rand()%22+1; //Random Y
			x = startPoint; 
			score +=10; //Change SCOREs
			xDir = +xDir; 
			//System("pause");

		}

		else if ( x == 0 )
		{
			lives--;
			srand ( time(NULL) );
			y= rand()%22+1; 
			x = startPoint;
		}

		if ( x == startPoint )
		{
			xDir = +xDir; 
		}


		x -= xDir;//add speed here

		


	}

	void Pacman::DisplayCharacters()
	{
		m_screenBuffer.DrawString( 30,0,  "SHOOT THOSE ENEMIES" ); //gAME TITLE
		

			
		char Score_buffer[50];
		m_screenBuffer.DrawString(60,2,"SCORE : ");
		 sprintf (Score_buffer, "%i",score);

		 char lives_buffer[50];
		m_screenBuffer.DrawString(60,3,"Lives : ");
		 sprintf (lives_buffer, "%i",lives);
			
		m_screenBuffer.DrawString( 68, 2, Score_buffer);//Draw Score
		m_screenBuffer.DrawString( 68, 3, lives_buffer);//Lives
		//m_screenBuffer.SetAttribute( 10, 15, EConsoleAttribute::FG_BLUE );


		m_screenBuffer.SetText( m_player.x, m_player.y, '>' );//Draw Player
//m_screenBuffer.SetAttribute( m_player.x, m_player.y, EConsoleAttribute::FG_BLUE );

		m_screenBuffer.SetText( ai_Fast[0].x, ai_Fast[0].y, 'F' );//Draw Ai  ENemy FAST
		m_screenBuffer.SetAttribute( ai_Fast[0].x, ai_Fast[0].y, EConsoleAttribute::FG_INTENSITY);

		m_screenBuffer.SetText( ai_Slow[0].x, ai_Slow[0].y, 'S' );//Draw Ai  ENemy SLOW
		m_screenBuffer.SetAttribute( ai_Slow[0].x, ai_Slow[0].y, EConsoleAttribute::FG_INTENSITY);

		m_screenBuffer.SetText( ai_Medium[0].x, ai_Medium[0].y, 'M' );//Draw Ai  ENemy Medium
		m_screenBuffer.SetAttribute( ai_Medium[0].x, ai_Medium[0].y, EConsoleAttribute::FG_INTENSITY);
		
		m_screenBuffer.DrawString(m_player.x-4,m_player.y-1, " /\\"   );							
		m_screenBuffer.DrawString(m_player.x-7, m_player.y," >+===D>" );
        m_screenBuffer.DrawString(m_player.x-4,m_player.y+1, " \\/"   );                                                      // \/  
	//	m_screenBuffer.SetAttribute( Straight.x, Straight.y, EConsoleAttribute::FG_RED);

//---------------------------------------------------------    Just having fun 
		char *stringA = "  ,_              .  /_";
		m_screenBuffer.DrawString( 24,12, stringA );
		char *stringB = " _/_)__(_/__(_/__/__/ (_";
		m_screenBuffer.DrawString( 24,13, stringB );   
		char *stringC = " /          _/_";
		m_screenBuffer.DrawString( 24,14, stringC );
		char *stringD = "/          (/";
		m_screenBuffer.DrawString( 24,15, stringD );
//------------------------------------------------------------


	}

	void Pacman::PrintBg(char ArrayZ[][79])
	{
for ( int i = 0; i < 24; ++i )
			{
				for ( int j = 0; j < 79; ++j )
				{

					if ( ArrayZ[i][j] == NULL )
					{
						m_screenBuffer.SetAttribute( j, i, EConsoleAttribute::BG_BLUE );
						m_screenBuffer.SetText( j,i, '. ' );
					}

					else 
					{

						m_screenBuffer.SetAttribute( j, i, EConsoleAttribute::BG_RED );
						m_screenBuffer.SetText( j,i, ' ' );

					}


				}
			}


	}

	void  Pacman::DisplayBackground(int &Xcoor, int &Ycoor )
	{


		m_screenBuffer.SetAttribute( Ycoor, Xcoor, EConsoleAttribute::BG_GREEN );
		m_screenBuffer.SetText( Ycoor,Xcoor, ' ' );

	}

char ArrayZ[24][79] = {
			{'*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','A','*','G','*','T','*','A','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*',},
			{'*',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'*'},
			{'*',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'*'},
			{'*',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'*'},
			{'*',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'*'},
			{'*',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'*'},
			{'*',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'*'},
			{'*',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'*'},
			{'*',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'*'},
			{'*',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'*'},
			{'*',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'*'},
			{'*',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'*'},
			{'*',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'*'},
			{'*',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'*'},
			{'*',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'*'},
			{'*',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'*'},
			{'*',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'*'},
			{'*',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'*'},
			{'*',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'*'},
			{'*',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'*'},
			{'*',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'*'},
			{'*',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'*'},
			{'*',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'*'},
			{'*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*'}
		};
	INT Pacman::Main( INT argNum, CHAR **ppArgs )
	{


	

		m_inputDevice.SetListener( this );

		Update();

		m_player.x = m_player.y = 10; // starting position of Player

		//Fast Ai properties
		ai_Fast[0].x = 110;
		ai_Fast[0].y = 10;
		ai_Fast[0].startPoint =110;
        ai_Fast[0].xDir = 1;//currently used for speed
		ai_Fast[0].yDir = 1; //La pa na gamit
		ai_Fast[0].Speed = 2;//La pa ni na gamit
		//Slow Ai properties
		ai_Slow[0].x = 78;
		ai_Slow[0].y = 20;
		ai_Slow[0].startPoint = 78;
	ai_Slow[0].xDir = .8f;
		ai_Slow[0].yDir = 1;
		ai_Slow[0].Speed = 2;//La pa ni na gamit
		//Medium Ai properties
		ai_Medium[0].x = 95;
		ai_Medium[0].y = 1;
		ai_Medium[0].startPoint = 95;
		ai_Medium[0].xDir = .6f;
		ai_Medium[0].yDir = 1;
		ai_Medium[0].Speed = 2; //La pa ni na gamit

		//Bullter stright properties







		

		

cout<<"\n\n\n\n ";
cout<<"\t       ^    ^    ^    ^       ^    ^    ^    ^    ^  "        <<endl 
    <<"\t      /S\   /T\   /A\   /R\      /S\   /C\   /R\   /A\   /P\ "<<endl 
    <<"\t     <___><___><___><___>   <___><___><___><___><___>"        <<endl;
   cout<<endl<<endl<<endl;


   cout<<"\t\t\t\tInstructions:"<<endl<<endl
	   <<"\t\t\tMOVEMENT: USE YOUR ARROW KEYS"<<endl<<endl
	   <<"\t\t\tFIRE: PRESS SPACEBAR TO FIRE\n\n\n\n\n"<<endl
       <<"\t\t\tPress Any KEy TO Start Game"<<endl<<endl;

		cin.get();										 
            

		bool MainGameLopp = 1; 

		while ( MainGameLopp )  //My main game Loop  start here :P
		{


ResetBulletPos();
PrintBg(ArrayZ); //Draw and Render BAckground
		
			DisplayCharacters(); //Draw all the Characters Needed( title, ais, etc.)

			//cout<<"YOUR SCORE : ";

			Update(); //to update functions(and some others)  like keyboard functionalities 
			ai_Fast[0].Update();
			ai_Slow[0].Update();
			ai_Medium[0].Update();


			m_screenBuffer.DisplayBuffer();//display everything drawn on top of this line of code


		} //End of game Loop 


		return 0;
	}

	void Pacman::OnMouseEvent( MouseEvent *pEvent )
	{


	}

	void Pacman::OnKeyboardEvent( KeyboardEvent *pEvent )
	{
				
		if ( pEvent->key ==VK_SPACE )
		{

			while(Straight.x <78)
			{
				//Update();
				//Sleep(30);
				
				
				Straight.x += .5;	


				
				

				
				PrintBg(ArrayZ);//Insert Function to draw the background again : passing a 2d array of characters to a function
				DisplayCharacters();
			m_screenBuffer.SetText(Straight.x, Straight.y, '-' );//Draw Ai  ENemy SLOW
				m_screenBuffer.SetAttribute( Straight.x, Straight.y, EConsoleAttribute::FG_RED);
				m_screenBuffer.DisplayBuffer();
				
	               
				if(Straight.x==ai_Fast[0].x&&Straight.y==ai_Fast[0].y)//If bullet hits enemy
				{
					
					m_screenBuffer.DrawString(Straight.x, Straight.y, "BOOM!!" ); //Draw Ai  ENemy SLOW
					ai_Fast[0].x = ai_Fast[0].startPoint+1;                              //Reset BUllet Position  + 1
					m_screenBuffer.DisplayBuffer();	
					ai_Fast[0].Update();											    //update bullet
													                               //display every movement
					
					//System("pause");
				


					break;

				}
				else if(Straight.x==ai_Medium[0].x&&Straight.y==ai_Medium[0].y)//hit
				{
					
					m_screenBuffer.DrawString(Straight.x, Straight.y, "BOOM!!" );//Draw Ai  ENemy Medium
					ai_Medium[0].x = ai_Medium[0].startPoint+1;
					ai_Medium[0].Update();
					m_screenBuffer.DisplayBuffer();
					ResetBulletPos();
					//System("pause");
					
					break;

				}

				else if(Straight.x==ai_Slow[0].x&&Straight.y==ai_Slow[0].y)//hit
				{
					
					m_screenBuffer.DrawString(Straight.x, Straight.y, "BOOM!!" );//Draw Ai  ENemy SLOW
					ai_Slow[0].x = ai_Slow[0].startPoint+1;
					ai_Slow[0].Update();
					m_screenBuffer.DisplayBuffer();
					ResetBulletPos();
					//System("pause");
					
					break;

				}



			}

			//ResetBulletPos();
			//			Straight.y = m_player.y;
			//Straight.x = m_player.x;
		}	

		if ( pEvent->key == VK_UP ){
			{
				m_player.y = m_player.y - 1.3; //Updates so every movement Bullet position follows Ship position
				ResetBulletPos();


			}
			
		}
		if ( pEvent->key == VK_DOWN )
		{

			m_player.y = m_player.y + 1.3;
		
		}

		//	ai_Slow.Update();

		if ( pEvent->key == VK_LEFT )
		{
			m_player.x = m_player.x - 1.3;
		}

		if ( pEvent->key == VK_RIGHT )
		{
			m_player.x = m_player.x + 1.3;
			
		}

	}

}

//#endif /* PSX_PLATFORM_WINDOWS_CONSOLE */


/*    |^   |_|   `/   |   |-|     */




